Computer programs are groups of instructions that describe actions to be performed by a computer or other processor-based device. When a computer program is loaded and executed on computer hardware, the computer will behave in a predetermined manner by following the instructions of the computer program. Accordingly, the computer becomes a specialized machine that performs the tasks prescribed by the instructions.
A programmer utilizing a programming language creates the instructions comprising a computer program. Typically, source code is specified or edited by a programmer manually and/or with help of an integrated development environment (IDE). By way of example, a programmer may choose to implement source code utilizing an object-oriented programming language (e.g., C#, VB, Java . . . ) where programmatic logic is specified as interactions between instances of classes or objects, among other things. Subsequently, the source code can be compiled or otherwise transformed to facilitate execution by a computer or like device.
A compiler produces code for a specific target from source code. For example, some compilers transform source code into native code for execution by a specific machine. Other compilers generate intermediate code from source code, where this intermediate code is subsequently interpreted dynamically at run time or compiled just-in-time (JIT) to facilitate cross-platform execution, for instance.
Compilers perform lexical, syntactic, and semantic analysis as well as code generation. A scanner or lexer performs lexical analysis to convert a sequence of characters into tokens based on a program language specification. A parser performs syntactic analysis of tokens provided by the lexer in an attempt to determine structure and often captures such structure in a parse tree in accordance with a formal language grammar. Subsequently, semantic analysis can be performed with respect to the parse tree to determine meaning associated with the code as well as perform type checking and binding, among other things. Finally, a code generator produces code in a target language as a function of the analysis performed.
Type checking is a process of verifying and enforcing type constraints. Programming languages employ type systems to classify data into types that define constraints on data or sets of values as well as allowable operations. This helps ensure program correctness, among other things. Accordingly, types are checked during the semantic analysis phase to ensure values and expressions are being utilized appropriately. In some instances, types are not explicit but rather need to be inferred from contextual information. Thus, type checking sometime necessitates type inference and binding of types to objects.
Knowledge of types is significant in a binding process. Binding refers to associating a value with an identifier or resolving a variable to its definition, among other things. Some programming languages allow overloading of constructs such as functions or methods. More specifically, objects of different types can include the same function or method names. It is only after an object type is determined that the correct definition is known.
However, program languages differ as to when binding occurs. Static or early-bound languages require binding to be performed at compile time. Dynamic or late-bound languages perform binding dynamically at runtime. Other languages employ a hybrid or dual approach in which they bind statically at compile time where possible and defer other binding to runtime. Here, two compilers are conventionally employed—one that operates at compile time to enable early binding and another that operates a runtime to perform late binding.